package com.lemon.smartsafety.ui.adapter.profile;

import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.lemon.smartsafety.R;
import com.lemon.smartsafety.app.AppService;
import com.lemon.smartsafety.app.EventTag;
import com.lemon.smartsafety.entity.event.user.ProfileExistEvent;
import com.lemon.smartsafety.entity.user.ProfileBaseModel;
import com.lemon.smartsafety.entity.user.ProfileCommonModel;
import com.lemon.smartsafety.utils.common.LoggerHelper;

import kale.adapter.item.AdapterItem;

/**
 * Created by Cooliean on 16/2/1.
 */
public class ProfileExist implements AdapterItem<ProfileBaseModel> {
    private LoggerHelper loggerHelper = new LoggerHelper(ProfileExist.class);


    private RelativeLayout mItemMainLayout;
    private View mTopDivider, mBottomDivider;
    private ImageView mImageIcon, mImageArrow;
    private TextView mItemText;


    @Override
    public int getLayoutResId() {
        return R.layout.item_profile_exist;
    }

    @Override
    public void bindViews(View root) {
        mItemMainLayout = (RelativeLayout) root.findViewById(R.id.itemMainLayout);
        mTopDivider = root.findViewById(R.id.top_divider);
        mBottomDivider = root.findViewById(R.id.bottom_divider);
        mImageIcon = (ImageView) root.findViewById(R.id.imageIcon);
        mImageArrow = (ImageView) root.findViewById(R.id.imageArrow);
        mItemText = (TextView) root.findViewById(R.id.itemText);
    }

    @Override
    public void setViews() {
    }


    @Override
    public void handleData(ProfileBaseModel profileBaseModel, int position) {
        if (profileBaseModel.getViewType() == ProfileViewType.TYPE_EXIST) {
            ProfileCommonModel common = (ProfileCommonModel) profileBaseModel;
            if (common.getTag() == ProfileTag.TAG_EXIST) {
                mItemMainLayout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        ProfileExistEvent event = new ProfileExistEvent();
                        event.setExist(true);
                        event.setTag(EventTag.TAG_PROFILE_EXIST);
                        AppService.getBus().post(event);
                    }
                });
            }
        }
    }
}
